import vxeTable from './vxe-table';
import { App } from 'vue';
import { userInfoStore } from '@/uni_modules/dx-admin/stores/user';
import { IconPark } from '@/uni_modules/dx-admin/common/iconPark';

const install = function (app: App) {
	const userStore = userInfoStore();
	app.use(vxeTable);
	// 注册图标
	IconPark(app);
	// 权限指令
	app.directive('permission', {
		mounted(el, binding) {
			const { value } = binding;
			if (value === true || value === void 0) return;
			const status = userStore.hasPermission(value);
			if (!value || !status) {
				el.parentNode.removeChild(el);
			}
		},
	});
};

export default {
	install,
};
